#Setup----------
#Load Libraries
library(xtable)
library(stargazer)
rm(list=ls())

#Load in Data
English<-read.csv("~/Desktop/Data/EEuropeData/EEurope/English.csv"); English$Language<-"English"
Estonian<-read.csv("~/Desktop/Data/EEuropeData/EEurope/Estonian.csv"); Estonian$Language<-"Estonian"
Latvian<-read.csv("~/Desktop/Data/EEuropeData/EEurope/Latvian.csv"); Latvian$Language<-"Latvian"
Lithuanian<-read.csv("~/Desktop/Data/EEuropeData/EEurope/Lithuanian.csv"); Lithuanian$Language<-"Lithuanian"
Polish<-read.csv("~/Desktop/Data/EEuropeData/EEurope/Polish.csv"); Polish$Language<-"Polish"
PolandPretest<-read.csv("~/Desktop/Data/EEuropeData/EEurope/PolandPretest.csv"); PolandPretest$Language<-"Pretest"
Romanian<-read.csv("~/Desktop/Data/EEuropeData/EEurope/Romanian.csv"); Romanian$Language<-"Romanian"

df<-rbind(English, Estonian, Latvian, Lithuanian, Polish, Romanian)
rm(English, Estonian, Latvian, Lithuanian, Polish, Romanian)

#Data Cleaning - Reconciliation 
df<-df[df$Consent==1,] #Remove people who failed the consent.
df<-df[df$AttnCheck==1,] #Remove people who failed the attention check.
df<-df[!is.na(df$Vet),] #Remove people who didn't get to the end. 
df<-df[df$ManCheck==1,] #Remove people who failed the manipulation check. 
df<-df[df$Duration..in.seconds.>358,] #Remove speeders
#ADD WHETHER METADATA (AGE) MATCHES REPORTED AGE
#ADD WHETHER OPEN-ENDS ARE TEXT

#Data Cleaning - Analysis 
df<-df[df$Consent==1,] #Remove people who failed the consent.
df<-df[df$State!=99,]
#df<-df[df$AttnCheck==1,] #Remove people who failed the attention check.
#df<-df[df$ManCheck==1,] #Remove people who failed the manipulation check. 

#For Methods Section----------
xtable(table(df$State))
baltics<-as.data.frame(subset(df,df$State==4 | df$State==3 | df$State==2))
nrow(baltics[,baltics$Age_1 > 64]) / nrow(baltics)

#Variable Cleaning--------
df$TreatLevel <- ifelse(grepl("High", df$Treatment_DO),1,0)
df$TreatType <- ifelse(grepl("Nuclear", df$Treatment_DO),1,0)

df$PolicyA <- ifelse(grepl("A:", df$Policy),1,0)
df$PolicyB <- ifelse(grepl("B:", df$Policy),1,0)
df$PolicyC <- ifelse(grepl("C:", df$Policy),1,0)
df$PolicyD <- ifelse(grepl("D:", df$Policy),1,0)
df$PolicyE <- ifelse(grepl("E:", df$Policy),1,0)
df$PolicyF <- ifelse(grepl("F:", df$Policy),1,0)

df$ApproveNuclear <- ifelse(grepl("1",df$Approve),1,0)

table(df$Target)
df$Target<-ifelse(df$Target=="Latvia" | df$Target == "Läti" | 
                  df$Target=="Latvija" | df$Target == "Łotwie" | 
                  df$Target=="Letonia",1,0)

#Experimental Results------------
summary(lm(data=df, Prolif ~ TreatLevel + TreatType)) #Almost Sig High Decrease Prolif
summary(lm(data=df, Vote ~ TreatLevel + TreatType))
summary(lm(data=df, Strengthen_US ~  TreatLevel + TreatType)) #High Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel + TreatType)) #High Decrease Strengthen NATO, Nuclear Increase Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel + TreatType)) #Nuclear Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel + TreatType)) #Nuclear Increase Strengthen Target
summary(lm(data=df, NEntrap ~  TreatLevel + TreatType)) #Nuclear Increase NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel + TreatType)) #Nuclear Increase CEntrap
summary(lm(data=df, Contribute ~  TreatLevel + TreatType))
summary(lm(data=df, ApproveNuclear ~  TreatLevel + TreatType)) #Nuclear Decreases Approve Nuclear

summary(lm(data=df, Prolif ~ TreatLevel * TreatType)) 
summary(lm(data=df, Vote ~ TreatLevel * TreatType))
summary(lm(data=df, Strengthen_US ~  TreatLevel * TreatType)) #High Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel * TreatType)) #High Decrease Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel * TreatType)) #Nuclear / High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel * TreatType)) 
summary(lm(data=df, NEntrap ~  TreatLevel * TreatType)) #Nuclear Decrease NEntrap, Nuclear x High Increase NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel * TreatType)) #Nuclear Increase CEntrap, Nuclear x High Increase CEntrap
summary(lm(data=df, Contribute ~  TreatLevel * TreatType))
summary(lm(data=df, ApproveNuclear ~  TreatLevel * TreatType)) 

summary(lm(data=df, Prolif ~ TreatLevel * TreatType + Target)) 
summary(lm(data=df, Vote ~ TreatLevel * TreatType + Target))
summary(lm(data=df, Strengthen_US ~  TreatLevel * TreatType + Target)) #Nuclear Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel * TreatType + Target)) #Nuclear Decrease Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel * TreatType + Target)) #Nuclear / High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel * TreatType + Target)) 
summary(lm(data=df, NEntrap ~  TreatLevel * TreatType + Target)) #Nuclear Decrease NEntrap, Nuclear x High Increase NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel * TreatType + Target)) #Nuclear Decrease CEntrap, Nuclear x High Increase CEntrap
summary(lm(data=df, Contribute ~  TreatLevel * TreatType + Target))
summary(lm(data=df, ApproveNuclear ~  TreatLevel * TreatType + Target)) 

summary(lm(data=df, Prolif ~ TreatLevel * TreatType * Target)) 
summary(lm(data=df, Vote ~ TreatLevel * TreatType * Target))
summary(lm(data=df, Strengthen_US ~  TreatLevel * TreatType * Target)) #Nuclear Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel * TreatType * Target)) #Nuclear Decrease Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel * TreatType * Target)) #Nuclear / High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel * TreatType * Target)) 
summary(lm(data=df, NEntrap ~  TreatLevel * TreatType * Target)) #Nuclear & High Decrease NEntrap, Nuclear x High Increase NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel * TreatType * Target)) 
summary(lm(data=df, Contribute ~  TreatLevel * TreatType * Target))
summary(lm(data=df, ApproveNuclear ~  TreatLevel * TreatType * Target)) 

summary(lm(data=df, Prolif ~ TreatLevel * TreatType + Language)) 
summary(lm(data=df, Vote ~ TreatLevel * TreatType + Language))
summary(lm(data=df, Strengthen_US ~  TreatLevel * TreatType + Language))  #Nuclear Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel * TreatType + Language)) #Nuclear Decrease Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel * TreatType + Language)) #Nuclear / High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel * TreatType + Language)) 
summary(lm(data=df, NEntrap ~  TreatLevel * TreatType + Language)) #Nuclear Decrease NEntrap, Nuclear x High Increase NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel * TreatType + Language)) #Nuclear Increase CEntrap, Nuclear x High Increase CEntrap
summary(lm(data=df, Contribute ~  TreatLevel * TreatType + Language))
summary(lm(data=df, ApproveNuclear ~  TreatLevel * TreatType + Language))

summary(lm(data=df, Prolif ~ TreatLevel + TreatType + Language)) #Nuclear decreases prolif
summary(lm(data=df, Vote ~ TreatLevel + TreatType + Language)) #Nuclear decreases vote
summary(lm(data=df, Strengthen_US ~  TreatLevel + TreatType + Language))  #Nuclear Decrease Strengthen US, High Increases 
summary(lm(data=df, Strengthen_NATO ~  TreatLevel + TreatType + Language)) #Nuclear Decrease Strengthen NATO, High Increases
summary(lm(data=df, Strengthen_Russia ~  TreatLevel + TreatType + Language)) #High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel + TreatType + Language)) #High Increases Strengthen Target
summary(lm(data=df, NEntrap ~  TreatLevel + TreatType + Language)) #High Increases NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel + TreatType + Language)) #High Increases CEntrap
summary(lm(data=df, Contribute ~  TreatLevel + TreatType + Language))
summary(lm(data=df, ApproveNuclear ~  TreatLevel + TreatType + Language)) #Nuclear Decreases Approve Nuclear

summary(lm(data=df, Prolif ~ TreatLevel + TreatType + Target + Language)) #Nuclear decreases prolif
summary(lm(data=df, Vote ~ TreatLevel + TreatType + Target + Language)) #Nuclear decreases vote
summary(lm(data=df, Strengthen_US ~  TreatLevel + TreatType + Target + Language))  #Nuclear Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel + TreatType + Target + Language)) #Nuclear Decrease Strengthen NATO, High Increases
summary(lm(data=df, Strengthen_Russia ~  TreatLevel + TreatType + Target + Language)) #High Increase Strengthen Russia
summary(lm(data=df, Strengthen_Target ~  TreatLevel + TreatType + Target + Language)) #High Increases Strengthen Target
summary(lm(data=df, NEntrap ~  TreatLevel + TreatType + Target + Language)) #High Increases NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel + TreatType + Target + Language)) #High Increases CEntrap
summary(lm(data=df, Contribute ~  TreatLevel + TreatType + Target + Language))
summary(lm(data=df, ApproveNuclear ~  TreatLevel + TreatType + Target + Language)) #Nuclear Decreases Approve Nuclear


summary(lm(data=df, Prolif ~ TreatLevel * TreatType * Target + Language)) 
summary(lm(data=df, Vote ~ TreatLevel * TreatType * Target + Language)) 
summary(lm(data=df, Strengthen_US ~  TreatLevel * TreatType * Target + Language))  #Nuclear Decrease Strengthen US
summary(lm(data=df, Strengthen_NATO ~  TreatLevel * TreatType * Target + Language)) #Nuclear Decrease Strengthen NATO
summary(lm(data=df, Strengthen_Russia ~  TreatLevel * TreatType * Target + Language)) 
summary(lm(data=df, Strengthen_Target ~  TreatLevel * TreatType * Target + Language)) 
summary(lm(data=df, NEntrap ~  TreatLevel * TreatType * Target + Language)) #High x Nuclear Increases NEntrap
summary(lm(data=df, CEntrap ~  TreatLevel * TreatType * Target + Language)) 
summary(lm(data=df, Contribute ~  TreatLevel * TreatType * Target + Language))
summary(lm(data=df, ApproveNuclear ~  TreatLevel * TreatType * Target + Language)) #Nuclear Decreases Approve Nuclear

table(df$NEntrap) #50%
table(df$CEntrap) #58

df$Treat<-ifelse(df$TreatLevel==1 & df$TreatType==1, "1", NA) #NukeHigh
df$Treat<-ifelse(df$TreatLevel==0 & df$TreatType==1, "2", df$Treat) #NukeLow
df$Treat<-ifelse(df$TreatLevel==1 & df$TreatType==0, "3", df$Treat) #ConHigh
df$Treat<-ifelse(df$TreatLevel==0 & df$TreatType==0, "4", df$Treat) #ConLow

summary(lm(data=df, Prolif ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1))
summary(lm(data=df, ApproveNuclear ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1)) #ConHigh & ConLow -> Higher Nuclear Approval
summary(lm(data=df, Vote ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1 + Vet)) 

summary(lm(data=df, Prolif ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1 + 
                        Know_NatSec + Know_RusUkWar + Favor_US + Favor_R + Favor_Uk + Favor_Target + Favor_U + Favor_NATO + 
                        Taboo_Reversed + Dove + Nationalism + ILaw + 
                        Align_R + Align_Uk + Align_Target + Align_NATO + Trust_US + Trust_R + Trust_NATO + Trust_U + 
                        Revenge + DemoPromo + USMil_Good + USMil_Effective + USMil_Responsive + USMil_Aggressive))

summary(lm(data=df, ApproveNuclear ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1 + 
                   Know_NatSec + Know_RusUkWar + Favor_US + Favor_R + Favor_Uk + Favor_Target + Favor_U + Favor_NATO + 
                   Taboo_Reversed + Dove + Nationalism + ILaw + 
                   Align_R + Align_Uk + Align_Target + Align_NATO + Trust_US + Trust_R + Trust_NATO + Trust_U + 
                   Revenge + DemoPromo + USMil_Good + USMil_Effective + USMil_Responsive + USMil_Aggressive)) #ConHigh/ConLow -> Higher Nuclear Approval

summary(lm(data=df, Vote ~ Treat + Language + Rightwing + Edu + Income + Female + Age_1 + 
                   Know_NatSec + Know_RusUkWar + Favor_US + Favor_R + Favor_Uk + Favor_Target + Favor_U + Favor_NATO + 
                   Taboo_Reversed + Dove + Nationalism + ILaw + 
                   Align_R + Align_Uk + Align_Target + Align_NATO + Trust_US + Trust_R + Trust_NATO + Trust_U + 
                   Revenge + DemoPromo + USMil_Good + USMil_Effective + USMil_Responsive + USMil_Aggressive))



summary(lm(data=df[df$Language=="English",], Prolif ~ TreatLevel + TreatType )) 
summary(lm(data=df[df$Language=="Estonian",], Prolif ~ TreatLevel + TreatType )) 
summary(lm(data=df[df$Language=="Latvian",], Prolif ~ TreatLevel + TreatType )) 
summary(lm(data=df[df$Language=="Lithuanian",], Prolif ~ TreatLevel + TreatType )) #Nuclear Decreases Prolif
summary(lm(data=df[df$Language=="Polish",], Prolif ~ TreatLevel + TreatType )) #High Increases Prolif
summary(lm(data=df[df$Language=="Romanian",], Prolif ~ TreatLevel + TreatType )) 

summary(lm(data=df[df$Language=="English",], Prolif ~ TreatLevel)) 
summary(lm(data=df[df$Language=="Estonian",], Prolif ~ TreatLevel)) 
summary(lm(data=df[df$Language=="Latvian",], Prolif ~ TreatLevel)) 
summary(lm(data=df[df$Language=="Lithuanian",], Prolif ~ TreatLevel)) #High Increases Prolif 
summary(lm(data=df[df$Language=="Polish",], Prolif ~ TreatLevel)) #High Increases Prolif
summary(lm(data=df[df$Language=="Romanian",], Prolif ~ TreatLevel)) 

#Table 1: Policy Preferences (& Rank Order Preferences for Appendix)-----------------

for(i in 1:nrow(df)){
df$SupportA[i] <- sum(sum(df$AB[i]==1,na.rm=T), sum(df$AC[i]==1,na.rm=T), sum(df$AD[i]==1,na.rm=T), sum(df$AE[i]==1,na.rm=T), sum(df$AF[i]==1,na.rm=T))
df$SupportA[i] <- df$SupportA[i] / sum(!is.na(df$AB[i]),!is.na(df$AC[i]),!is.na(df$AD[i]),!is.na(df$AE[i]),!is.na(df$AF[i]))

df$SupportB[i] <- sum(sum(df$AB[i]==2,na.rm=T), sum(df$BC[i]==2,na.rm=T), sum(df$BD[i]==2,na.rm=T), sum(df$BE[i]==2,na.rm=T), sum(df$BF[i]==2,na.rm=T))
df$SupportB[i] <- df$SupportB[i] / sum(!is.na(df$AB[i]),!is.na(df$BC[i]),!is.na(df$BD[i]),!is.na(df$BE[i]),!is.na(df$BF[i]))

df$SupportC[i] <- sum(sum(df$AC[i]==3,na.rm=T), sum(df$BC[i]==3,na.rm=T), sum(df$CD[i]==3,na.rm=T), sum(df$CE[i]==3,na.rm=T), sum(df$CF[i]==3,na.rm=T))
df$SupportC[i] <- df$SupportC[i] / sum(!is.na(df$AC[i]),!is.na(df$BC[i]),!is.na(df$CD[i]),!is.na(df$CE[i]),!is.na(df$CF[i]))

df$SupportD[i] <- sum(sum(df$AD[i]==4,na.rm=T), sum(df$BD[i]==4,na.rm=T), sum(df$CD[i]==4,na.rm=T), sum(df$DE[i]==4,na.rm=T), sum(df$DF[i]==4,na.rm=T))
df$SupportD[i] <- df$SupportD[i] / sum(!is.na(df$AD[i]),!is.na(df$BD[i]),!is.na(df$CD[i]),!is.na(df$DE[i]),!is.na(df$DF[i]))

df$SupportE[i] <- sum(sum(df$AE[i]==5,na.rm=T), sum(df$BE[i]==5,na.rm=T), sum(df$CE[i]==5,na.rm=T), sum(df$DE[i]==5,na.rm=T), sum(df$EF[i]==5,na.rm=T))
df$SupportE[i] <- df$SupportE[i] / sum(!is.na(df$AE[i]),!is.na(df$BE[i]),!is.na(df$CE[i]),!is.na(df$DE[i]),!is.na(df$EF[i]))

df$SupportF[i] <- sum(sum(df$AF[i]==6,na.rm=T), sum(df$BF[i]==6,na.rm=T), sum(df$CF[i]==6,na.rm=T), sum(df$DF[i]==6,na.rm=T), sum(df$EF[i]==6,na.rm=T))
df$SupportF[i] <- df$SupportF[i] / sum(!is.na(df$AF[i]),!is.na(df$BF[i]),!is.na(df$CF[i]),!is.na(df$DF[i]),!is.na(df$EF[i]))
}

supports<-c(mean(df$SupportA, na.rm=T),
            mean(df$SupportB, na.rm=T),
            mean(df$SupportC, na.rm=T),
            mean(df$SupportD, na.rm=T),
            mean(df$SupportE, na.rm=T),
            mean(df$SupportF, na.rm=T))
cnames<-c("A (Sanctions)","B (Bilateral Summit)","C (Deploy on Location)","D (Deploy to You)","E (Multilateral Summit)","F (Reiterate Guarantee")
supports<-round(supports,4)*100
xtable(cbind(cnames,supports))
   
preferAover<-c(0,
                sum(df$AB==1,na.rm=T)/sum(table(df$AB)),
               sum(df$AC==1,na.rm=T)/sum(table(df$AC)),
               sum(df$AD==1,na.rm=T)/sum(table(df$AD)),
               sum(df$AE==1,na.rm=T)/sum(table(df$AE)),
               sum(df$AF==1,na.rm=T)/sum(table(df$AF)))*100

preferBover<-c(sum(df$AB==2,na.rm=T)/sum(table(df$AB)),
               0,
               sum(df$BC==2,na.rm=T)/sum(table(df$BC)),
               sum(df$BD==2,na.rm=T)/sum(table(df$BD)),
               sum(df$BE==2,na.rm=T)/sum(table(df$BE)),
               sum(df$BF==2,na.rm=T)/sum(table(df$BF)))*100

preferCover<-c(sum(df$AC==3,na.rm=T)/sum(table(df$AC)),
               sum(df$BC==3,na.rm=T)/sum(table(df$BC)),
               0,
               sum(df$CD==3,na.rm=T)/sum(table(df$CD)),
               sum(df$CE==3,na.rm=T)/sum(table(df$CE)),
               sum(df$CF==3,na.rm=T)/sum(table(df$CF)))*100

preferDover<-c(sum(df$AD==4,na.rm=T)/sum(table(df$AD)),
               sum(df$BD==4,na.rm=T)/sum(table(df$BD)),
               sum(df$CD==4,na.rm=T)/sum(table(df$CD)),
               0,
               sum(df$DE==4,na.rm=T)/sum(table(df$DE)),
               sum(df$DF==4,na.rm=T)/sum(table(df$DF)))*100

preferEover<-c(sum(df$AE==5,na.rm=T)/sum(table(df$AE)),
               sum(df$BE==5,na.rm=T)/sum(table(df$BE)),
               sum(df$CE==5,na.rm=T)/sum(table(df$CE)),
               sum(df$DE==5,na.rm=T)/sum(table(df$DE)),
               0,
               sum(df$EF==5,na.rm=T)/sum(table(df$EF)))*100

preferFover<-c(sum(df$AF==6,na.rm=T)/sum(table(df$AF)),
               sum(df$BF==6,na.rm=T)/sum(table(df$BF)),
               sum(df$CF==6,na.rm=T)/sum(table(df$CF)),
               sum(df$DF==6,na.rm=T)/sum(table(df$DF)),
               sum(df$EF==6,na.rm=T)/sum(table(df$EF)),
               0)*100
tab2<-cbind(preferAover,preferBover,preferCover,preferDover,preferEover,preferFover)
row.names(tab2)<-c("A","B","C","D","E","F")
xtable(tab2)


#Table 2: Characteristics --------------
df$Support_Binary<-ifelse(df$Support>2,1,0)
df$Effective_Binary<-ifelse(df$Effective>2,1,0)
df$Economy_Binary<-ifelse(df$Economy>2,1,0)
df$Reputation_Binary<-ifelse(df$Reputation>2,1,0)
df$Interests_Binary<-ifelse(df$Interests>2,1,0)
df$Capabilities_Binary<-ifelse(df$Capabilities>2,1,0)
df$Defend_Binary<-ifelse(df$Defend>2,1,0)

#Percents - Binary
Support_Binary <- c(mean(df$Support_Binary[df$PolicyA==1]),
             mean(df$Support_Binary[df$PolicyB==1]),
             mean(df$Support_Binary[df$PolicyC==1]),
             mean(df$Support_Binary[df$PolicyD==1]),
             mean(df$Support_Binary[df$PolicyE==1]),
             mean(df$Support_Binary[df$PolicyF==1]))

Effective_Binary <- c(mean(df$Effective_Binary[df$PolicyA==1]),
               mean(df$Effective_Binary[df$PolicyB==1]),
               mean(df$Effective_Binary[df$PolicyC==1]),
               mean(df$Effective_Binary[df$PolicyD==1]),
               mean(df$Effective_Binary[df$PolicyE==1]),
               mean(df$Effective_Binary[df$PolicyF==1]))

Economy_Binary <- c(mean(df$Economy_Binary[df$PolicyA==1]),
             mean(df$Economy_Binary[df$PolicyB==1]),
             mean(df$Economy_Binary[df$PolicyC==1]),
             mean(df$Economy_Binary[df$PolicyD==1]),
             mean(df$Economy_Binary[df$PolicyE==1]),
             mean(df$Economy_Binary[df$PolicyF==1]))

Reputation_Binary <- c(mean(df$Reputation_Binary[df$PolicyA==1]),
                mean(df$Reputation_Binary[df$PolicyB==1]),
                mean(df$Reputation_Binary[df$PolicyC==1]),
                mean(df$Reputation_Binary[df$PolicyD==1]),
                mean(df$Reputation_Binary[df$PolicyE==1]),
                mean(df$Reputation_Binary[df$PolicyF==1]))

Interests_Binary <- c(mean(df$Interests_Binary[df$PolicyA==1]),
               mean(df$Interests_Binary[df$PolicyB==1]),
               mean(df$Interests_Binary[df$PolicyC==1]),
               mean(df$Interests_Binary[df$PolicyD==1]),
               mean(df$Interests_Binary[df$PolicyE==1]),
               mean(df$Interests_Binary[df$PolicyF==1]))

Capabilities_Binary <- c(mean(df$Capabilities_Binary[df$PolicyA==1]),
                  mean(df$Capabilities_Binary[df$PolicyB==1]),
                  mean(df$Capabilities_Binary[df$PolicyC==1]),
                  mean(df$Capabilities_Binary[df$PolicyD==1]),
                  mean(df$Capabilities_Binary[df$PolicyE==1]),
                  mean(df$Capabilities_Binary[df$PolicyF==1]))

Defend_Binary <- c(mean(df$Defend_Binary[df$PolicyA==1]),
            mean(df$Defend_Binary[df$PolicyB==1]),
            mean(df$Defend_Binary[df$PolicyC==1]),
            mean(df$Defend_Binary[df$PolicyD==1]),
            mean(df$Defend_Binary[df$PolicyE==1]),
            mean(df$Defend_Binary[df$PolicyF==1]))

table1<-cbind(Support_Binary,Effective_Binary,Economy_Binary,Reputation_Binary,Interests_Binary,Capabilities_Binary,Defend_Binary)
row.names(table1)<-c("Sanctions","Bilateral Summit","In-Theater Deployment","Deterrent Deployment","Multilateral Summit","Reiterate Guarantee")
xtable(round(table1,2))


table1<-cbind(Reputation_Binary,Interests_Binary,Defend_Binary, Capabilities_Binary)
row.names(table1)<-c("Sanctions","Bilateral Summit","In-Theater Deployment","Deterrent Deployment","Multilateral Summit","Reiterate Guarantee")
table1<-table1*100
xtable(round(table1,2))

#question: do evaluations of capability vary significantly?
t.test(df$Capabilities_Binary[df$PolicyA==1],df$Capabilities_Binary[df$PolicyA!=1]) 
t.test(df$Capabilities_Binary[df$PolicyB==1],df$Capabilities_Binary[df$PolicyB!=1]) 
t.test(df$Capabilities_Binary[df$PolicyC==1],df$Capabilities_Binary[df$PolicyC!=1]) 
t.test(df$Capabilities_Binary[df$PolicyD==1],df$Capabilities_Binary[df$PolicyD!=1])
t.test(df$Capabilities_Binary[df$PolicyE==1],df$Capabilities_Binary[df$PolicyE!=1])
t.test(df$Capabilities_Binary[df$PolicyF==1],df$Capabilities_Binary[df$PolicyF!=1])

t.test(df$Defend_Binary[df$Capabilities==4],df$Defend_Binary[df$Capabilities<4])
t.test(df$Reputation_Binary[df$Capabilities==4],df$Reputation_Binary[df$Capabilities<4])
t.test(df$Interests_Binary[df$Capabilities==4],df$Interests_Binary[df$Capabilities<4])

#is there variation in perceptions of resolve? 
mean(df$Reputation_Binary,na.rm=T)
sd(df$Reputation_Binary,na.rm=T)
mean(df$Interests_Binary,na.rm=T)
sd(df$Interests_Binary,na.rm=T)
mean(df$Defend_Binary,na.rm=T)
sd(df$Defend_Binary,na.rm=T)


#question: do evaluations of reputation vary significantly?
t.test(df$Reputation_Binary[df$PolicyA==1],df$Reputation_Binary[df$PolicyA!=1]) #0.11 + 
t.test(df$Reputation_Binary[df$PolicyB==1],df$Reputation_Binary[df$PolicyB!=1]) #0.07 -
t.test(df$Reputation_Binary[df$PolicyC==1],df$Reputation_Binary[df$PolicyC!=1]) 
t.test(df$Reputation_Binary[df$PolicyD==1],df$Reputation_Binary[df$PolicyD!=1])
t.test(df$Reputation_Binary[df$PolicyE==1],df$Reputation_Binary[df$PolicyE!=1])
t.test(df$Reputation_Binary[df$PolicyF==1],df$Reputation_Binary[df$PolicyF!=1])

#question: do evaluations of reputation vary significantly?
t.test(df$Interests_Binary[df$PolicyA==1],df$Interests_Binary[df$PolicyA!=1]) 
t.test(df$Interests_Binary[df$PolicyB==1],df$Interests_Binary[df$PolicyB!=1]) 
t.test(df$Interests_Binary[df$PolicyC==1],df$Interests_Binary[df$PolicyC!=1]) 
t.test(df$Interests_Binary[df$PolicyD==1],df$Interests_Binary[df$PolicyD!=1]) #0.06 + 
t.test(df$Interests_Binary[df$PolicyE==1],df$Interests_Binary[df$PolicyE!=1])
t.test(df$Interests_Binary[df$PolicyF==1],df$Interests_Binary[df$PolicyF!=1])

#question: do evaluations of reputation vary significantly?
t.test(df$Defend_Binary[df$PolicyA==1],df$Defend_Binary[df$PolicyA!=1]) 
t.test(df$Defend_Binary[df$PolicyB==1],df$Defend_Binary[df$PolicyB!=1]) 
t.test(df$Defend_Binary[df$PolicyC==1],df$Defend_Binary[df$PolicyC!=1]) 
t.test(df$Defend_Binary[df$PolicyD==1],df$Defend_Binary[df$PolicyD!=1])
t.test(df$Defend_Binary[df$PolicyE==1],df$Defend_Binary[df$PolicyE!=1])
t.test(df$Defend_Binary[df$PolicyF==1],df$Defend_Binary[df$PolicyF!=1])

#what if you only compare to certain alternatives?
t.test(df$Defend_Binary[df$PolicyA==1],df$Defend_Binary[df$PolicyC==1 | df$PolicyD==1])
t.test(df$Defend_Binary[df$PolicyF==1],df$Defend_Binary[df$PolicyB==1 | df$PolicyE==1])

t.test(df$Interests_Binary[df$PolicyA==1],df$Interests_Binary[df$PolicyC==1 | df$PolicyD==1])
t.test(df$Interests_Binary[df$PolicyF==1],df$Interests_Binary[df$PolicyB==1 | df$PolicyE==1])

t.test(df$Reputation_Binary[df$PolicyA==1],df$Reputation_Binary[df$PolicyC==1 | df$PolicyD==1]) #+
t.test(df$Reputation_Binary[df$PolicyF==1],df$Reputation_Binary[df$PolicyB==1 | df$PolicyE==1]) #+

t.test(df$Capabilities_Binary[df$PolicyA==1],df$Capabilities_Binary[df$PolicyC==1 | df$PolicyD==1]) 
t.test(df$Capabilities_Binary[df$PolicyF==1],df$Capabilities_Binary[df$PolicyB==1 | df$PolicyE==1]) 

t.test(df$Defend_Binary[df$PolicyA==1],df$Defend_Binary[df$PolicyF==1])
t.test(df$Defend_Binary[df$PolicyB==1 | df$PolicyE==1],df$Defend_Binary[df$PolicyC==1 | df$PolicyD==1])

t.test(df$Interests_Binary[df$PolicyA==1],df$Interests_Binary[df$PolicyF==1])
t.test(df$Interests_Binary[df$PolicyB==1 | df$PolicyE==1],df$Interests_Binary[df$PolicyC==1 | df$PolicyD==1])

t.test(df$Reputation_Binary[df$PolicyA==1],df$Reputation_Binary[df$PolicyF==1])
t.test(df$Reputation_Binary[df$PolicyB==1 | df$PolicyE==1],df$Reputation_Binary[df$PolicyC==1 | df$PolicyD==1])

t.test(df$Capabilities_Binary[df$PolicyA==1],df$Capabilities_Binary[df$PolicyF==1])
t.test(df$Capabilities_Binary[df$PolicyB==1 | df$PolicyE==1],df$Capabilities_Binary[df$PolicyC==1 | df$PolicyD==1])

t.test(df$Defend_Binary[df$PolicyA==1 | df$PolicyF==1],df$Defend_Binary[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
t.test(df$Interests_Binary[df$PolicyA==1 | df$PolicyF==1],df$Interests_Binary[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
t.test(df$Reputation_Binary[df$PolicyA==1 | df$PolicyF==1],df$Reputation_Binary[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
t.test(df$Capabilities_Binary[df$PolicyA==1 | df$PolicyF==1],df$Capabilities_Binary[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])

t.test(df$Support_Binary[df$PolicyA==1 | df$PolicyF==1],df$Support_Binary[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])

#Policy Effectiveness------
table1<-cbind(Effective_Binary,Defend_Binary)
row.names(table1)<-c("Sanctions","Bilateral Summit","In-Theater Deployment","Deterrent Deployment","Multilateral Summit","Reiterate Guarantee")
table1<-table1*100
xtable(round(table1,2))

#question: do evaluations of effectiveness vary significantly?
t.test(df$Effective_Binary[df$PolicyA==1],df$Effective_Binary[df$PolicyA!=1]) 
t.test(df$Effective_Binary[df$PolicyB==1],df$Effective_Binary[df$PolicyB!=1]) 
t.test(df$Effective_Binary[df$PolicyC==1],df$Effective_Binary[df$PolicyC!=1]) 
t.test(df$Effective_Binary[df$PolicyD==1],df$Effective_Binary[df$PolicyD!=1])
t.test(df$Effective_Binary[df$PolicyE==1],df$Effective_Binary[df$PolicyE!=1])
t.test(df$Effective_Binary[df$PolicyF==1],df$Effective_Binary[df$PolicyF!=1])


round(table(df$Effective[df$PolicyA==1])/sum(table(df$Effective[df$PolicyA==1])),4)*100
round(table(df$Effective[df$PolicyB==1])/sum(table(df$Effective[df$PolicyB==1])),4)*100
round(table(df$Effective[df$PolicyC==1])/sum(table(df$Effective[df$PolicyC==1])),4)*100
round(table(df$Effective[df$PolicyD==1])/sum(table(df$Effective[df$PolicyD==1])),4)*100
round(table(df$Effective[df$PolicyE==1])/sum(table(df$Effective[df$PolicyE==1])),4)*100
round(table(df$Effective[df$PolicyF==1])/sum(table(df$Effective[df$PolicyF==1])),4)*100

t.test(df$Effective[df$PolicyA==1],df$Effective[df$PolicyA!=1]) #0.1 + 
t.test(df$Effective[df$PolicyB==1],df$Effective[df$PolicyB!=1]) #0.05 - 
t.test(df$Effective[df$PolicyC==1],df$Effective[df$PolicyC!=1]) 
t.test(df$Effective[df$PolicyD==1],df$Effective[df$PolicyD!=1])
t.test(df$Effective[df$PolicyE==1],df$Effective[df$PolicyE!=1]) #0.1 -
t.test(df$Effective[df$PolicyF==1],df$Effective[df$PolicyF!=1])

t.test(df$Effective_Binary[df$PolicyA==1],df$Effective_Binary[df$PolicyC==1 | df$PolicyD==1])
t.test(df$Effective_Binary[df$PolicyF==1],df$Effective_Binary[df$PolicyB==1 | df$PolicyE==1])

#is there variation in perceptions of effectiveness? 
mean(df$Effective_Binary,na.rm=T)
sd(df$Effective_Binary,na.rm=T)

#what if you only compare to certain alternatives?
t.test(df$Effective[df$PolicyA==1],df$Effective[df$PolicyC==1 | df$PolicyD==1])
t.test(df$Effective[df$PolicyF==1],df$Effective[df$PolicyB==1 | df$PolicyE==1]) #<0.05

t.test(df$Effective[df$PolicyA==1],df$Effective[df$PolicyF==1])
t.test(df$Effective[df$PolicyB==1 | df$PolicyE==1],df$Effective[df$PolicyC==1 | df$PolicyD==1]) #<0.05

t.test(df$Effective[df$PolicyA==1 | df$PolicyF==1],df$Effective[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
#<0.05

#Escalation Potential---------------
df$PolicyTreat<-ifelse(df$PolicyA==1,"A",NA)
df$PolicyTreat<-ifelse(df$PolicyB==1,"B",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyC==1,"C",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyD==1,"D",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyE==1,"E",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyF==1,"F",df$PolicyTreat)

NukTarget <- c(mean(df$RNukT_ConLike[df$PolicyA==1]),
               mean(df$RNukT_ConLike[df$PolicyB==1]),
               mean(df$RNukT_ConLike[df$PolicyC==1]),
               mean(df$RNukT_ConLike[df$PolicyD==1]),
               mean(df$RNukT_ConLike[df$PolicyE==1]),
               mean(df$RNukT_ConLike[df$PolicyF==1]))

ThreatTarget <- c(mean(df$RThreatT_ConLike[df$PolicyA==1]),
               mean(df$RThreatT_ConLike[df$PolicyB==1]),
               mean(df$RThreatT_ConLike[df$PolicyC==1]),
               mean(df$RThreatT_ConLike[df$PolicyD==1]),
               mean(df$RThreatT_ConLike[df$PolicyE==1]),
               mean(df$RThreatT_ConLike[df$PolicyF==1]))

df$RThreatT_NukLike<-ifelse(df$RThreatT_NukLike==2,0,df$RThreatT_NukLike)
df$RThreatT_NukLike<-ifelse(df$RThreatT_NukLike==3,1,df$RThreatT_NukLike)
table(df$RThreatT_NukLike)
ThreatTarget_NVariation <- c(mean(df$RThreatT_NukLike[df$PolicyA==1]),
                  mean(df$RThreatT_NukLike[df$PolicyB==1]),
                  mean(df$RThreatT_NukLike[df$PolicyC==1]),
                  mean(df$RThreatT_NukLike[df$PolicyD==1]),
                  mean(df$RThreatT_NukLike[df$PolicyE==1]),
                  mean(df$RThreatT_NukLike[df$PolicyF==1]))


table1<-cbind(ThreatTarget,ThreatTarget_NVariation)
row.names(table1)<-c("Sanctions","Bilateral Summit","In-Theater Deployment","Deterrent Deployment","Multilateral Summit","Reiterate Guarantee")
table1<-table1*100
xtable(round(table1,2))


t.test(df$RNukT_ConLike[df$PolicyA==1 | df$PolicyF==1],df$RNukT_ConLike[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
#<0.05
t.test(df$RThreatT_ConLike[df$PolicyA==1 | df$PolicyF==1],df$RThreatT_ConLike[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
#<0.05
t.test(df$RThreatT_NukLike[df$PolicyA==1 | df$PolicyF==1],df$RThreatT_NukLike[df$PolicyB==1 | df$PolicyC==1 | df$PolicyD==1 | df$PolicyE==1])
#<0.05


mean(df$RNukT2_NukApprove)
mean(df$RThreatT2_NukApprove)

#"RConT_ConLike"         "RNukT_ConLike"         "RThreatT_ConLike" 
#"RConU_ConLike"         "RNukU_ConLike"         "RThreatU_ConLike"      


#"RConT_NukLike"         "RNukT_NukLike"         "RThreatT_NukLike"      
#"RConU_NukLike"         "RNukU_NukLike"         "RThreatU_NukLike"    


#"RConT2_NukApprove"     "RNukT2_NukApprove"     "RThreatT2_NukApprove" 
#"RConU2_NukApprove"     "RNukU2_NukApprove"     "RThreatU2_NukApprove" 

#Additional Analysis-------------------
df$PolicyTreat<-ifelse(df$PolicyA==1,"A",NA)
df$PolicyTreat<-ifelse(df$PolicyB==1,"B",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyC==1,"C",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyD==1,"D",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyE==1,"E",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyF==1,"F",df$PolicyTreat)

mod1<-(lm(data=df, Support ~ PolicyTreat))
mod2<-(lm(data=df, Effective ~ PolicyTreat))
mod3<-(lm(data=df, Economy ~ PolicyTreat))
mod4<-(lm(data=df, Reputation ~ PolicyTreat))
mod5<-(lm(data=df, Interests ~ PolicyTreat))
mod6<-(lm(data=df, Capabilities ~ PolicyTreat))
mod7<-(lm(data=df, Defend ~ PolicyTreat))
stargazer(mod1,mod2,mod3,mod4,mod5,mod6,mod7,single.row=T)

df$PolicyTreat<-ifelse(df$PolicyA==1,"4",NA)
df$PolicyTreat<-ifelse(df$PolicyB==1,"3",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyC==1,"2",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyD==1,"1",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyE==1,"5",df$PolicyTreat)
df$PolicyTreat<-ifelse(df$PolicyF==1,"6",df$PolicyTreat)

mod1<-(lm(data=df, Support ~ PolicyTreat))
mod2<-(lm(data=df, Effective ~ PolicyTreat))
mod3<-(lm(data=df, Economy ~ PolicyTreat))
mod4<-(lm(data=df, Reputation ~ PolicyTreat))
mod5<-(lm(data=df, Interests ~ PolicyTreat))
mod6<-(lm(data=df, Capabilities ~ PolicyTreat))
mod7<-(lm(data=df, Defend ~ PolicyTreat))
stargazer(mod1,mod2,mod3,mod4,mod5,mod6,mod7,single.row=T)


summary(lm(data=df, Defend ~ Support + Effective + Economy + Reputation + Interests + Capabilities))
#Effective -, Interests > Capabilities > Reputation > Support (All +)

mod0<-(lm(data=df, Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod1<-(lm(data=df[df$PolicyA==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod2<-(lm(data=df[df$PolicyB==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod3<-(lm(data=df[df$PolicyC==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod4<-(lm(data=df[df$PolicyD==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod5<-(lm(data=df[df$PolicyE==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
mod6<-(lm(data=df[df$PolicyF==1,], Support ~ Defend + Effective + Economy + Reputation + Interests + Capabilities))
stargazer(mod0,mod1,mod2,mod3,mod4,mod5,mod6,single.row=T)


mod0<-(lm(data=df, Defend ~ Effective + Economy + Reputation + Interests + Capabilities))
mod1<-(lm(data=df[df$PolicyA==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
mod2<-(lm(data=df[df$PolicyB==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
mod3<-(lm(data=df[df$PolicyC==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
mod4<-(lm(data=df[df$PolicyD==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
mod5<-(lm(data=df[df$PolicyE==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
mod6<-(lm(data=df[df$PolicyF==1,], Defend ~  Effective + Economy + Reputation + Interests + Capabilities))
stargazer(mod0,mod1,mod2,mod3,mod4,mod5,mod6,single.row=T)


#Ukraine-------------
a <- table(df$UkraineTrust,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Align_Uk,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)


a <- table(df$Favor_Uk,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Favor_R,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Align_R,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Trust_R,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Trust_US,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Trust_NATO,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

a <- table(df$Trust_U,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)




a <- table(df$Know_RusUkWar,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)


df$Prolif_Binary<-ifelse(df$Prolif>3,1,0)
a <- table(df$Prolif_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)


df$Taboo_Binary<-ifelse(df$Taboo_Reversed>2,0,1)
a <- table(df$Taboo_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

df$Dove_Binary<-ifelse(df$Dove>2,1,0)
a <- table(df$Taboo_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

df$ILaw_Binary<-ifelse(df$ILaw>2,1,0)
table(df$ILaw_Binary)/sum(table(df$ILaw_Binary))

df$DemoPromo_Binary<-ifelse(df$DemoPromo>2,1,0)
table(df$DemoPromo_Binary)/sum(table(df$DemoPromo_Binary))
a <- table(df$DemoPromo_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

df$USMil_GoodBinary<-ifelse(df$USMil_Good>2,1,0)
table(df$USMil_GoodBinary)/sum(table(df$USMil_GoodBinary))
a <- table(df$USMil_GoodBinary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

df$Vote_Binary<-ifelse(df$Vote>2,1,0)
table(df$Vote_Binary)/sum(table(df$Vote_Binary))
a <- table(df$Vote_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)

df$Contribute_Binary<-ifelse(df$Contribute>2,1,0)
table(df$Contribute_Binary)/sum(table(df$Contribute_Binary))
a <- table(df$Contribute_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)


df$TNW_Binary<-ifelse(df$TNW>2,1,0)
table(df$TNW_Binary)/sum(table(df$TNW_Binary))
a <- table(df$TNW_Binary,df$State)
b <- c(sum(a[,1]), sum(a[,2]), sum(a[,3]), sum(a[,4]), sum(a[,5]), sum(a[,6]))
a[,1] <- a[,1]/b[1]
a[,2] <- a[,2]/b[2]
a[,3] <- a[,3]/b[3]
a[,4] <- a[,4]/b[4]
a[,5] <- a[,5]/b[5]
a[,6] <- a[,6]/b[6]
xtable(round(a,4)*100)


table(df$RConU2_NukApprove)/sum(table(df$RConU2_NukApprove))
table(df$RNukU2_NukApprove)/sum(table(df$RNukU2_NukApprove))
table(df$RThreatU2_NukApprove)/sum(table(df$RThreatU2_NukApprove))

table(df$RConT2_NukApprove)/sum(table(df$RConT2_NukApprove))
table(df$RNukT2_NukApprove)/sum(table(df$RNukT2_NukApprove))
table(df$RThreatT2_NukApprove)/sum(table(df$RThreatT2_NukApprove))
